﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SQLServerSyncClient
{
    class LogFileTools
    {
        #region 写日志
        public static void WriteLog(string txt)
        {
            string strFilePath = ".\\FailedLogFiles\\";
            if (!Directory.Exists(strFilePath))
                Directory.CreateDirectory(strFilePath);

            string curDate = DateTime.Now.ToString();
            string DATE = DateTime.Now.ToString("yyyy-MM-dd");
            strFilePath = strFilePath + "FailedData_"+ DATE + ".log";

            FileStream fs = new FileStream(strFilePath, FileMode.Append);
            StreamWriter sw = new StreamWriter(fs, Encoding.Default);

            txt = curDate + "----" + txt;

            try
            {
                sw.WriteLine(txt);
            }
            finally
            {
                sw.Close();
                fs.Close();
            }
        }
        #endregion
    }
}
